package com.averroes
{
	/**
	 * A simple static calculus class to do things such as diff'ing arrays. These functions will be similar to what you'd see in Matlab.
	 * @author marram
	 * 
	 */	
	public class Calculus
	{
		/**
		 * diff(array), for a array X, is [X(2)-X(1)  X(3)-X(2) ... X(n)-X(n-1)].
		 * @param array
		 * @return 
		 * 
		 */		
		public static function diff(array:Array):Array
		{
			var ret:Array = new Array();
			for (var n:int = 1; n < array.length; n++)
			{
				ret[n] = array[n]-array[n-1];
			} 
			ret.shift();
			return ret;
		}		
	}
}